
import {wasm_init,wasm_hasInit,wasm_getImports,wasm_getExports} from "../libWasm.js"
var _export:{[id:string]:any};
export async function InitWasm()
{
     //先替换掉我们想导出给wasm的函数
    var imports = wasm_getImports();
    imports["hello"] =()=>
    {
        console.log("hello   call from wasm");
    }
    //然后启动wasm
    wasm_init();
    //等待wasm准备好
    while (!wasm_hasInit()) {        
        await new Promise(resolve => requestAnimationFrame(resolve));
    }
    //执行两个测试
    _export = wasm_getExports();
    var v = _export.Add(3, 4);
    console.log("test1 add=" + v);
    _export.Good();
    console.log("test2 good");
}
export function GetWasmFunc(name:string):any
{
    return _export[name];
}
export function GetWasmExports():any
{
    return _export;
}